﻿package mortal.game.view.friend
{
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class FriendIcon extends HintBaseIcon
    {
        private var _applyNumLabel:GTextFiled;
        private static var _instance:FriendIcon;

        public function FriendIcon(param1:String)
        {
            super(param1);
            if (_instance)
            {
                throw new Error("FriendIcon 单例");
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.size = 9;
            this._applyNumLabel = UIFactory.gTextField("", 14 + 4, 11 + 2, 20, 20, this, _loc_1);
            this.configEventListener(MouseEvent.CLICK, this.onOpenFriendApplyWin);
            Dispatcher.addEventListener(EventName.FriendApplyListUpdate, this.onApplyListUpdate);
            return;
        }// end function

        private function onOpenFriendApplyWin(event:MouseEvent) : void
        {
            FriendApplyWin.instance.show();
            return;
        }// end function

        private function updateApplyNum() : void
        {
            var _loc_1:* = Cache.instance.friend.applyList.length;
            if (_loc_1 != 0)
            {
                this._applyNumLabel.text = Cache.instance.friend.applyList.length.toString();
            }
            else
            {
                this._applyNumLabel.text = "";
            }
            return;
        }// end function

        private function onApplyListUpdate(event:DataEvent) : void
        {
            this.updateApplyNum();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._applyNumLabel.dispose(param1);
            this._applyNumLabel = null;
            Dispatcher.removeEventListener(EventName.FriendApplyListUpdate, this.onApplyListUpdate);
            return;
        }// end function

        public static function get instance() : FriendIcon
        {
            if (!_instance)
            {
                _instance = new FriendIcon(ImagesConst.FriendHintIcon);
            }
            return _instance;
        }// end function

    }
}
